package securityproject;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import securityproject.utils.Constants;

public class ConfigurationManager extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = -5196898850265880899L;

	public static final String LOG_DISPLAY = "logDisplay";
	public static final String UNKNIWN_ONLY = "unknown_only";
	public static final String NOT_DISMISSED_ONLY = "not_dismissed_only";
	public static final String NOT_DISSMISSED_UNKNOWN = "not_dismissed_unknow";

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {

		String logDisplay = req.getParameter(LOG_DISPLAY);

		if (logDisplay.equals(UNKNIWN_ONLY)) {
			Constants.setXSLSuffixRuleFile(Constants.XSL_RULE_UNKNOWN_ONLY);

		} else if (logDisplay.equals(NOT_DISMISSED_ONLY)) {
			Constants
					.setXSLSuffixRuleFile(Constants.XSL_RULE_NOT_DISMISSED_ONLY);

		} else if (logDisplay.equals(NOT_DISSMISSED_UNKNOWN)) {
			Constants
					.setXSLSuffixRuleFile(Constants.XSL_RULE_NOT_DISMISSED_UNKNOWN);

		} else {
			// default unknown only
			Constants.setXSLSuffixRuleFile(Constants.XSL_RULE_UNKNOWN_ONLY);
		}

		resp.sendRedirect("../ManageConfigurations.jsp");
		
	}

}
